package com.numberone.controller;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DBUtil {

    private final static String URL = "jdbc:sqlserver://47.94.218.75:1433;DatabaseName=StudentManager";
    private static final String USER="LiuYue";
    private static final String PASSWORD="15603333319Slf";
    private static Connection conn=null;

    static {
        try {
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            conn=(Connection)DriverManager.getConnection(URL,USER,PASSWORD);
            conn.setAutoCommit(false);
        }catch (ClassNotFoundException e){
            System.out.println("数据库驱动加载失败");
            e.printStackTrace();
        }catch (SQLException e){
            System.out.println("数据库获取连接失败");
            e.printStackTrace();
        }
    }

    public static Connection getConnection(){
        return conn;
    }


}
